﻿using ShareFrame.Business.Base_Manage;
using ShareFrame.Entity.Base_Manage;
using ShareFrame.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using ShareFrame.IBusiness.Base_Manage;

namespace ShareFrame.Api.Controllers.Base_Manage
{
    [Route("/Base_Manage/[controller]/[action]")]
    [OpenApiTag("代码生成接口", Description = "用于系统初始化代码生成操作")]
    [ApiExplorerSettings(GroupName = "系统管理")]
    public class BuildCodeController : BaseApiController
    {
        #region DI

        public BuildCodeController(IBuildCodeBusiness buildCodeBus)
        {
            _buildCodeBus = buildCodeBus;
        }

        IBuildCodeBusiness _buildCodeBus { get; }

        #endregion

        /// <summary>
        /// 获取全部数据库连接信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public List<Base_DbLink> GetAllDbLink()
        {
            return _buildCodeBus.GetAllDbLink();
        }

        /// <summary>
        /// 查询指定数据库所有数据表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public List<DbTableInfo> GetDbTableList(DbTablesInputDTO input)
        {
            return _buildCodeBus.GetDbTableList(input.linkId);
        }

        /// <summary>
        /// 根据条件创建对应模板代码层
        /// </summary>
        /// <param name="input"></param>
        [HttpPost]
        public void Build(BuildInputDTO input)
        {
            _buildCodeBus.Build(input);
        }
    }
}